package cn.iocoder.yudao.module.promotion.groupon.service.admin;

import cn.iocoder.yudao.framework.business.basic.dao.query.CoreQueryWrapper;
import cn.iocoder.yudao.framework.business.basic.pojo.vo.UserSimpleVO;
import cn.iocoder.yudao.framework.business.basic.service.impl.MemberScopeService;
import cn.iocoder.yudao.module.api.member.user.MemberUserApi;
import cn.iocoder.yudao.module.promotion.groupon.dao.GrouponPackageFavoriteMapper;
import cn.iocoder.yudao.module.promotion.groupon.pojo.dto.AdminGrouponPackageFavoriteQueryDTO;
import cn.iocoder.yudao.module.promotion.groupon.pojo.po.GrouponPackageFavorite;
import cn.iocoder.yudao.module.promotion.groupon.pojo.vo.AdminGrouponPackageFavoriteVO;
import jakarta.annotation.Nonnull;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

import java.util.Collection;
import java.util.Map;

/**
 * 产品收藏 Service 实现类
 *
 * @author 山野羡民
 */
@Service
@Validated
public class AdminGrouponPackageFavoriteServiceImpl extends MemberScopeService<GrouponPackageFavorite, AdminGrouponPackageFavoriteVO, AdminGrouponPackageFavoriteQueryDTO> implements AdminGrouponPackageFavoriteService {
    @Resource
    private GrouponPackageFavoriteMapper grouponPackageFavoriteMapper;

    @Resource
    private MemberUserApi memberUserApi;

    @Nonnull
    @Override
    protected CoreQueryWrapper<GrouponPackageFavorite> buildQueryWrapper(AdminGrouponPackageFavoriteQueryDTO param) {
        CoreQueryWrapper<GrouponPackageFavorite> wrapper = super.buildQueryWrapper(param);
        wrapper.eq("user_id", param.getUserId());
        wrapper.eq("recycled", false);
        return wrapper;
    }

    @Override
    protected GrouponPackageFavoriteMapper getInjectedMapper() {
        return grouponPackageFavoriteMapper;
    }

    @Nonnull
    @Override
    protected Map<Long, UserSimpleVO> getUserSimpleMap(Collection<Long> userIds) {
        return memberUserApi.getUserSimpleMap(userIds);
    }

}
